#include "qabstractspinboxhost.h"

#include "qcommonstruct.h"
#include "qabstractproperty.h"
#include "qpropertyfactory.h"

#include <QAbstractSpinBox>

using namespace SHAREDLIB;

QAbstractSpinBoxHost::QAbstractSpinBoxHost(QObject *object):
    QWidgetHost(object)
{
    QAbstractProperty *pro;

    pro=QPropertyFactory::createProperty("Bool");
    if(pro!=NULL)
    {
        pro->setAttribute("name","frame");
        pro->setAttribute("property_name",tr("Frame"));
        pro->setAttribute("group","Attributes");
        addProperty(pro);
    }

    pro=QPropertyFactory::createProperty("Bool");
    if(pro!=NULL)
    {
        pro->setAttribute("name","wrapping");
        pro->setAttribute("property_name",tr("Wrapping"));
        pro->setAttribute("group","Attributes");
        addProperty(pro);
    }

    pro=QPropertyFactory::createProperty("Bool");
    if(pro!=NULL)
    {
        pro->setAttribute("name","readOnly");
        pro->setAttribute("property_name",tr("ReadOnly"));
        pro->setAttribute("group","Attributes");
        addProperty(pro);
    }

    pro=QPropertyFactory::createProperty("Enum");
    if(pro!=NULL)
    {
        pro->setAttribute("name","buttonSymbols");
        pro->setAttribute("property_name",tr("ButtonSymbols"));
        pro->setAttribute("group","Attributes");
        ComboItems items;
        tagComboItem item;

        item.m_text=tr("UpDownArrows");
        item.m_value=QAbstractSpinBox::UpDownArrows;
        items.append(item);

        item.m_text=tr("NoButtons");
        item.m_value=QAbstractSpinBox::NoButtons;
        items.append(item);

        QVariant v;
        v.setValue<ComboItems>(items);
        pro->setAttribute("items",v);
        addProperty(pro);
    }

    pro=QPropertyFactory::createProperty("Enum");
    if(pro!=NULL)
    {
        pro->setAttribute("name","alignment");
        pro->setAttribute("property_name",tr("Alignment"));
        pro->setAttribute("group","Attributes");
        ComboItems items;
        tagComboItem item;

        item.m_text=tr("AlignLeft");
        item.m_value=Qt::AlignLeft;
        items.append(item);

        item.m_text=tr("AlignRight");
        item.m_value=Qt::AlignRight;
        items.append(item);

        item.m_text=tr("AlignHCenter");
        item.m_value=Qt::AlignHCenter;
        items.append(item);

        QVariant v;
        v.setValue<ComboItems>(items);
        pro->setAttribute("items",v);
        pro->setValue(Qt::AlignLeft);
        addProperty(pro);
    }

    appendMemery("readOnly");
    appendMemery("frame");
    appendMemery("wrapping");

}

void QAbstractSpinBoxHost::setFrame(bool frame)
{
    setPropertyValue("frame",frame);
}

bool QAbstractSpinBoxHost::frame()
{
    return getPropertyValue("frame").toBool();
}

void QAbstractSpinBoxHost::setWraping(bool wraping)
{
    setPropertyValue("wraping",wraping);
}

bool QAbstractSpinBoxHost::wraping()
{
    return getPropertyValue("wraping").toBool();
}

void QAbstractSpinBoxHost::setReadOnly(bool readonly)
{
    setPropertyValue("readOnly",readonly);
}

bool QAbstractSpinBoxHost::readonly()
{
    return getPropertyValue("readOnly").toBool();
}

void QAbstractSpinBoxHost::setButtonSymbols(int buttonSymbols)
{
    setPropertyValue("buttonSymbols",buttonSymbols);
}

int QAbstractSpinBoxHost::buttonSymbols()
{
    return getPropertyValue("buttonSymbols").toInt();
}

void QAbstractSpinBoxHost::setAlignment(int alignment)
{
    setPropertyValue("alignment",alignment);
}

int QAbstractSpinBoxHost::alignment()
{
    return getPropertyValue("alignment").toInt();
}
